package com.yfp.client.mapper;

import com.yfp.client.domain.ClientIntegral;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *
 * @description 针对表【client_integral(客户积分)】的数据库操作Mapper
 * @createDate 2025-03-05 11:00:35
 * @Entity com.yfp.client.domain.ClientIntegral
 */
public interface ClientIntegralMapper extends BaseMapper<ClientIntegral> {

    /**
     * 查询积分明细
     *
     * @param clientId
     * @return
     */
    List<ClientIntegral> getByClientId(String clientId);

    /**
     * 统计积分
     *
     * @param clientId
     * @return
     */
    int sumIntegralByClientId(String clientId);


    /**
     * 添加积分
     *
     * @param clientIntegral
     * @return
     */
    int insert(ClientIntegral clientIntegral);

    /**
     * 修改状态
     *
     * @param orderId
     * @param status
     * @return
     */
    int editStatusByOrderId(@Param("orderId") String orderId, @Param("status") Integer status);


    /**
     * 查询
     *
     * @param orderId
     * @return
     */
    ClientIntegral findByOrderId(String orderId);

    /**
     * 根据订单号修改状态和积分
     *
     * @param orderSn
     */
    void updateStatusAndIntegral(@Param("orderSn") String orderSn, @Param("surplusIntegral") Integer surplusIntegral);

    /**
     * 根据订单号获取积分记录
     * @param orderSn
     * @return
     */
    ClientIntegral getByOrderSn(String orderSn);
}
